//
// Created by LiuYou on 2021/5/8.
//

#include <cstdio>
#include <cstring>
#include <iostream>
#include "CMyString.hpp"

/**
 * @brief 添加赋值运算符函数
 */
int
main() {

#ifdef TEST_C_STRING
    {
        const char* ptr = "ni";
        // 2, 字符串的字符个数。
        std::fprintf(stdout, "%zu\n", std::strlen(ptr));

        // 8, 即一个指针所占的内存。
        std::fprintf(stdout, "%lu\n", sizeof(ptr));
    }
#endif

    CMyString cMyString1("ni");


    std::fprintf(stdout, "%s\n", cMyString1.getMPData());

    {
        CMyString cMyString2(nullptr);
        std::fprintf(stdout, "%s length: %zu\n", cMyString2.getMPData(), std::strlen(cMyString2.getMPData()));
        cMyString2 = cMyString1;
        std::fprintf(stdout, "%s\n", cMyString2.getMPData());
        std::fprintf(stdout, "%s length: %zu\n", cMyString2.getMPData(), std::strlen(cMyString2.getMPData()));
    }


    {
        CMyString cMyString2("chong");
        std::fprintf(stdout, "%s length: %zu\n", cMyString2.getMPData(), std::strlen(cMyString2.getMPData()));
        cMyString2 = cMyString1;
        std::fprintf(stdout, "%s\n", cMyString2.getMPData());
        std::fprintf(stdout, "%s length: %zu\n", cMyString2.getMPData(), std::strlen(cMyString2.getMPData()));
    }


    return 0;
}